
class RegisterApi:

    # 封装获取图片验证码
    @classmethod
    def captcha_img_api(cls, session):
        session.get(
            "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.9475916959588275")

    # 封装注册接口
    @classmethod
    def register_api(cls, session, body):
        url = "http://hmshop-test.itheima.net/Home/user/reg.html"
        head = {"Content-Type": "application/x-www-form-urlencoded"}
        resp = session.post(url=url, headers=head, data=body)
        print(resp.json())
        return resp


# if __name__ == '__main__':
#     session = requests.session()
#     body = {
#         "username": "15738649722",
#         "verify_code": "8888",
#         "password": "123456",
#         "password2": "123456"
#     }
#     RegisterApi.captcha_img_api(session)
#     RegisterApi.register_api(session, body)
